<template>
	<div class="bg  weui-panel">
		<div class="weui-cell" style="padding: 0.5rem;">
			<input type="button" class="btn returnBtn" @click="goBack" value="返回"></input>
			<input type="button" class="btn" style="display: flex;margin-left: 65%;padding: 3px 8px;"  value="新增" @click="addCase"></input>
		</div>

		<div class="weui-cells">
			<div class="weui-panel__bd">
				<a href="javascript:" v-for="(val,index) in staffCases" class="weui-media-box weui-media-box_appmsg">
					<div class="weui-media-box__hd">
						<img class="weui-media-box__thumb" :src="val.caseImgPath" alt="">
					</div>
					<div class="weui-media-box__bd" @click="seeDetail(val.caseNo)">
						<h5 class="weui-media-box__title">{{val.caseName}}</h5>
						<p class="weui-media-box__desc">{{val.caseShowDesc}}</p>
						<p  class="weui-media-box__desc">价格:{{val.caseSale}}</p>
						<p  class="weui-media-box__desc">优惠价格:{{val.caseSaleDz}}</p>
					</div>
				</a>
			</div>

		</div>
	</div>
</template>

<script>
	import uwLoadJs from '@/utils/uwLoad'
	import constant from '@/utils/constant'
	import apis from '@/utils/apis'
	import {
		getCaseList
	} from '@/apis/tech/tech'
	export default {
		
		data() {
			return {
				staffCases: [],
				showMsgFlag: false,
				userInfo: {},
				account: '',
				title: '课程信息',
			}
		},
		created() {
				
			this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
			this.account = this.$route.params.account
			this.getCaseList();
		},
		methods: {
			//新增课程
			addCase(){
				this.$router.push({name:"addCaseInfo"});
			},
			goBack() {
				this.$router.go(-1);
			},
			seeDetail(caseNo) {
				this.$router.push({name:"caseMsg",params:{"title":this.title,"isSuper":this.userInfo.userInfo.position,"caseNo":caseNo}})
			},

			getCaseList() {
				this.staffCases = [];
				if (!this.account) {
					this.account = '';
				}
				this.$showLoading({
					showLoadingToastFlag:true,
				});
				let url = apis.getCaseList + "?account=" + this.account;
				getCaseList(url).then(res => {
					if (res.resultCode == constant.SUCCESS && res.data != null) {
						this.staffCases = res.data;
						this.staffCases.forEach(item =>{
							if(item.caseDesc.length>8){
								item['caseShowDesc'] = item.caseDesc.substring(0,5)+'...';
							} else{
								item['caseShowDesc'] = item.caseDesc;
							}
						})
					}
					this.$hideLoading();
				}).catch(err => {
					this.$hideLoading();
				})
			}
		}
	}
</script>

<style scoped="scoped">
		@import "../../assets/css/returnBtn.css";

.backBtn {
		width: 3.125rem;
		display: block;
		text-align: center;
		line-height: 100%;
		padding: 0.3em;
		font: 16px Arial, sans-serif bold;
		font-style: normal;
		text-decoration: none;
		margin: 2px;
		vertical-align: text-bottom;
		zoom: 1;
		outline: none;
		font-size-adjust: none;
		font-stretch: normal;
		border-radius: 50px;
		box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
		text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
		color: #fefee9;
		border: 0.2px solid #2299ff;
		background-repeat: repeat;
		background-size: auto;
		background-origin: padding-box;
		background-clip: padding-box;
		background-color: #3399ff;
		background: linear-gradient(to bottom, #eeeff9 0%, #3399ff 100%);
	}
</style>
